﻿@using CatalogModel

@model Manager.Models.MaterialClassViewModel

@{
	ViewBag.Title = "Details";
	Layout = "~/Views/Shared/_Layout.cshtml";
	var type = Model.Item.GetType();
	var itemID = type.GetProperty("ID").GetValue(Model.Item);
}

<h2>Details</h2>

<div>
	<h4>@Model.TypeName</h4>
	<hr />

	@foreach (var prop in type.GetProperties())
	{
		<div class="row">
			@{
				var val = type.GetProperty(prop.Name).GetValue(Model.Item);

				if (val is ICodelist)
				{
					var value = (ICodelist)val;
					<div class="form-group">
						@Html.Label(prop.Name, htmlAttributes: new { @class = "control-label col-md-3" })
						<div class="col-md-9">
							<p>@value.ShortDescription</p>
						</div>
					</div>
				}
				else if (prop.PropertyType.Namespace.Contains("System") || prop.PropertyType.Name == "UnitType")
				{
					<div class="form-group">
						@Html.Label(prop.Name, htmlAttributes: new { @class = "control-label col-md-3" })
						<div class="col-md-9">
							<p>@val</p>
						</div>
					</div>
				}
			}
		</div>
	}
</div>
<br>
<div>
	<p>
		@Html.ActionLink("Edit", "Edit", new { id = itemID, tn = Model.TypeName }) |
		@Html.ActionLink("Back to List", "Index", new { n = Model.TypeName })
	</p>
</div>